<?php

/**
 * 用户注册，登录
 */
class MemberController extends Controller {

    public function actions() {
        return array(
            'captcha' => array(
                'class' => 'CCaptchaAction',
                'minLength'=>5, 
                'maxLength'=>5,
            ),
        );
    }


    //用户注册
    public function actionIndex() {
        $membersModel = new Members('register');
        if(isset($_POST['ajax']) && $_POST['ajax'] == 'member-form'){
            echo CActiveForm::validate($membersModel);
            Yii::app()->end();
        }

        if(isset($_POST['Members'])){
            $membersModel->attributes = $_POST['Members'];
            if ($membersModel->save()){
                $this->redirect ('site/index');
            }
                
        }
        $this->render('index', array('model'=>$membersModel));
    }

    //用户登录
    public function actionLogin() {
        $membersModel = new Members('login');

         $this->render('login', array('model'=>$membersModel));
    }

}